/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * GiaodienAdmin.java
 *
 * Created on Dec 8, 2012, 2:52:28 AM
 */
package doancnpm;
import com.toedter.calendar.IDateEditor;
import connect.connect;
import java.awt.Container;
import java.awt.Rectangle;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.sql.ResultSet;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Vector;


public class GiaodienAdmin extends javax.swing.JFrame {

    DefaultTableModel tblmodelthanhvien;
    ResultSet rsthanhvien1;
    ResultSet rsthanhvien2;
    ResultSet rsdungcu;
    DefaultTableModel tblmodeldungcu;
    
    public GiaodienAdmin() {
        initComponents();
        tblmodelthanhvien = (DefaultTableModel) jTable1.getModel();
        tblmodeldungcu = (DefaultTableModel) tabdungcu.getModel();
        loadthanhvien();
        loaddungcu();
    }
    
public void loaddungcu(){
    connect obj = new connect();
    Connection con = obj.connect();
    
    btnSua.setEnabled(false);
    btnXoa.setEnabled(false);
    
    while(tblmodelthanhvien.getRowCount()>0)
    {
        tblmodelthanhvien.removeRow(0);
    }
    String sql = "EXEC sp_Thanhvien_GetByAll";
    try
    {
        rsthanhvien1 = obj.executeSQL(sql);
        while(rsthanhvien1.next())
        {
            Vector v =new Vector();
            v.addElement(rsthanhvien1.getString("Mathanhvien"));
            v.addElement(rsthanhvien1.getString("Tenthanhvien"));
            v.addElement(rsthanhvien1.getString("Gioitinh"));
            v.addElement(rsthanhvien1.getString("Ngaysinh"));
            v.addElement(rsthanhvien1.getString("Dienthoai"));
            v.addElement(rsthanhvien1.getString("Diachi"));
            tblmodelthanhvien.addRow(v);
        }
       jTable1.setModel(tblmodelthanhvien);
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
}

public void loadthanhvien(){
    connect obj = new connect();
    Connection con = obj.connect();
    
    btnSua.setEnabled(false);
    btnXoa.setEnabled(false);
    
    while(tblmodelthanhvien.getRowCount()>0)
    {
        tblmodelthanhvien.removeRow(0);
    }
    String sql = "EXEC sp_Thanhvien_GetByAll";
    try
    {
        rsthanhvien1 = obj.executeSQL(sql);
        while(rsthanhvien1.next())
        {
            Vector v =new Vector();
            v.addElement(rsthanhvien1.getString("Mathanhvien"));
            v.addElement(rsthanhvien1.getString("Tenthanhvien"));
            v.addElement(rsthanhvien1.getString("Gioitinh"));
            v.addElement(rsthanhvien1.getString("Ngaysinh"));
            v.addElement(rsthanhvien1.getString("Dienthoai"));
            v.addElement(rsthanhvien1.getString("Diachi"));
            tblmodelthanhvien.addRow(v);
        }
       jTable1.setModel(tblmodelthanhvien);
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
}
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jTextField2 = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        tabdungcu = new javax.swing.JTable();
        jLabel22 = new javax.swing.JLabel();
        txtdcMa = new javax.swing.JTextField();
        txtdcNsx = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        txtdcTen = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        txtdcGia = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        txtdcChucnang = new javax.swing.JTextField();
        btndcThem = new javax.swing.JButton();
        btndcXoa = new javax.swing.JButton();
        jLabel29 = new javax.swing.JLabel();
        txttimkiemdungcu = new javax.swing.JTextField();
        btntimkiemdungcu = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        txtmathanhvien = new javax.swing.JTextField();
        txttenthanhvien = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtsdt = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txttendangnhap = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        txtmatkhau = new javax.swing.JPasswordField();
        txtlaimatkhau = new javax.swing.JPasswordField();
        btnthemthanhvien = new javax.swing.JButton();
        btnsuathanhvien = new javax.swing.JButton();
        btnxoathanhvien = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        txtdiachi = new javax.swing.JTextField();
        cbbgioitinh = new javax.swing.JComboBox();
        cldngaysinh = new com.toedter.calendar.JDateChooser();
        jLabel27 = new javax.swing.JLabel();
        cbbcapdo = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        txttimkiem = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtManoidung = new javax.swing.JTextField();
        txtTennoidung = new javax.swing.JTextField();
        txtMota = new javax.swing.JTextField();
        txtMadungcu = new javax.swing.JTextField();
        txtMachiphi = new javax.swing.JTextField();
        txtChiphi = new javax.swing.JTextField();
        btnThem = new javax.swing.JButton();
        btnSua = new javax.swing.JButton();
        btnXoa = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 255)));

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã thành viên", "Mã lớp", "Tên lớp", "Mã khung giờ", "Khung giờ", "Mã người hướng dẫn", "Tên người hướng dẫn"
            }
        ));
        jScrollPane3.setViewportView(jTable3);

        jLabel18.setText("Mã thành viên :");

        jLabel19.setText("Mã lớp :");

        jLabel20.setText("Tên lớp :");

        jLabel21.setText("Người hướng dẫn");

        jTextField3.setText("jTextField3");

        jTextField4.setText("jTextField4");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel18)
                            .addComponent(jLabel19))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField2)
                            .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE))
                        .addGap(60, 60, 60)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel21))
                        .addGap(29, 29, 29)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 773, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(89, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Quản lý lớp học", jPanel2);

        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 255)));

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 793, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 461, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Quản lý khuyến mại", jPanel5);

        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 255)));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 793, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 461, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("Thay đổi mật khẩu", jPanel6);

        tabdungcu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã dụng cụ", "Tên dụng cụ", "Nơi sản xuất", "Giá", "Chức năng"
            }
        ));
        jScrollPane4.setViewportView(tabdungcu);

        jLabel22.setText("Mã dụng cụ:");

        jLabel23.setText("Tên dụng cụ:");

        jLabel24.setText("Nơi sản xuất:");

        jLabel25.setText("Giá:");

        jLabel26.setText("Chức năng:");

        btndcThem.setFont(new java.awt.Font("Tahoma", 0, 14));
        btndcThem.setForeground(new java.awt.Color(0, 0, 204));
        btndcThem.setText("Thêm dụng cụ");

        btndcXoa.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        btndcXoa.setForeground(new java.awt.Color(0, 0, 204));
        btndcXoa.setText("Xóa dụng cụ");

        jLabel29.setText("Nhập tên dụng cụ");

        txttimkiemdungcu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txttimkiemdungcuActionPerformed(evt);
            }
        });

        btntimkiemdungcu.setForeground(new java.awt.Color(0, 0, 204));
        btntimkiemdungcu.setText("Tìm kiếm");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel22)
                            .addComponent(jLabel26)
                            .addComponent(jLabel23)
                            .addComponent(jLabel24)
                            .addComponent(jLabel25))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(txtdcNsx)
                                .addComponent(txtdcTen)
                                .addComponent(txtdcMa, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
                                .addComponent(txtdcGia)
                                .addComponent(txtdcChucnang))
                            .addComponent(btndcThem))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 46, Short.MAX_VALUE)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 522, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(btndcXoa)
                        .addGap(205, 205, 205))))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(338, 338, 338)
                .addComponent(jLabel29)
                .addGap(18, 18, 18)
                .addComponent(txttimkiemdungcu, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btntimkiemdungcu)
                .addContainerGap(139, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel29)
                    .addComponent(txttimkiemdungcu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btntimkiemdungcu))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel22)
                            .addComponent(txtdcMa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel23)
                            .addComponent(txtdcTen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(txtdcNsx, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel25)
                            .addComponent(txtdcGia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel26)
                            .addComponent(txtdcChucnang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(46, 46, 46)
                        .addComponent(btndcThem))
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addComponent(btndcXoa)
                .addContainerGap(39, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Quản lý dụng cụ tập luyện", jPanel4);

        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 255)));

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã thành viên", "Tên thành vên", "Giới tính", "Ngày sinh", "SĐT", "Địa chỉ"
            }
        ));
        jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jTable1);

        jLabel3.setText("Mã thành viên:");

        jLabel4.setText("Tên thành viên:");

        jLabel5.setText("Giới tính:");

        jLabel6.setText("Ngày sinh:");

        jLabel7.setText("SĐT:");

        jLabel8.setText("Tên đăng nhập:");

        jLabel9.setText("Mật khẩu:");

        jLabel10.setText("Nhập lại mật khẩu:");

        btnthemthanhvien.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnthemthanhvien.setForeground(new java.awt.Color(0, 0, 204));
        btnthemthanhvien.setText("Thêm Thành Viên");
        btnthemthanhvien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnthemthanhvienActionPerformed(evt);
            }
        });

        btnsuathanhvien.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnsuathanhvien.setForeground(new java.awt.Color(0, 0, 204));
        btnsuathanhvien.setText("Sửa Thông Tin");
        btnsuathanhvien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsuathanhvienActionPerformed(evt);
            }
        });

        btnxoathanhvien.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnxoathanhvien.setForeground(new java.awt.Color(0, 0, 204));
        btnxoathanhvien.setText("Xóa Thành Viên");
        btnxoathanhvien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnxoathanhvienActionPerformed(evt);
            }
        });

        jLabel11.setText("Địa chỉ:");

        cbbgioitinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Chọn giới tính", "Nam", "Nữ" }));

        jLabel27.setText("Cấp độ:");

        cbbcapdo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Thành viên", "Quản lý" }));

        jLabel28.setText("Nhập tên thành viên:");

        jButton1.setForeground(new java.awt.Color(0, 0, 204));
        jButton1.setText("Tìm kiếm");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel10)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txtlaimatkhau))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel9)
                            .addGap(45, 45, 45)
                            .addComponent(txtmatkhau))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txttendangnhap))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel4)
                                .addComponent(jLabel5)
                                .addComponent(jLabel11)
                                .addComponent(jLabel6)
                                .addComponent(jLabel3)
                                .addComponent(jLabel7))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(cbbgioitinh, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(txtsdt)
                                .addComponent(cldngaysinh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(txttenthanhvien)
                                .addComponent(txtmathanhvien, javax.swing.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
                                .addComponent(txtdiachi))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel27)
                        .addGap(37, 37, 37)
                        .addComponent(cbbcapdo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(61, 61, 61)
                        .addComponent(jLabel28)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txttimkiem, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32)
                        .addComponent(jButton1))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(17, 17, 17))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(btnthemthanhvien)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 149, Short.MAX_VALUE)
                .addComponent(btnsuathanhvien)
                .addGap(120, 120, 120)
                .addComponent(btnxoathanhvien)
                .addGap(81, 81, 81))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(jButton1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, 0, 0, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(35, 35, 35)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtmathanhvien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(22, 22, 22)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel28)
                                    .addComponent(txttimkiem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(14, 14, 14)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(txttenthanhvien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(cbbgioitinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(cldngaysinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(txtsdt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(txtdiachi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(txttendangnhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(12, 12, 12)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(txtmatkhau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtlaimatkhau, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbbcapdo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel27))))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnthemthanhvien)
                    .addComponent(btnsuathanhvien)
                    .addComponent(btnxoathanhvien))
                .addContainerGap(56, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Quản lý thành viên", jPanel1);

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 255)));

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã nội dung", "Tên nội dung", "Mô tả", "Mã dụng cụ", "Mã chi phí", "Chi phí"
            }
        ));
        jScrollPane2.setViewportView(jTable2);

        jLabel12.setText("Mã nội dung :");

        jLabel13.setText("Tên nội dung :");

        jLabel14.setText("Mô tả :");

        jLabel15.setText("Mã dụng cụ :");

        jLabel16.setText("Mã chi phí :");

        jLabel17.setText("Chi phí :");

        btnThem.setBackground(new java.awt.Color(0, 0, 0));
        btnThem.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnThem.setForeground(new java.awt.Color(255, 0, 0));
        btnThem.setText("Thêm nội dung");

        btnSua.setBackground(new java.awt.Color(0, 0, 0));
        btnSua.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnSua.setForeground(new java.awt.Color(255, 0, 51));
        btnSua.setText("Sửa nội dung");

        btnXoa.setBackground(new java.awt.Color(0, 0, 0));
        btnXoa.setFont(new java.awt.Font("Tahoma", 0, 14));
        btnXoa.setForeground(new java.awt.Color(255, 0, 0));
        btnXoa.setText("Xóa nội dung");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel12)
                    .addComponent(jLabel14)
                    .addComponent(jLabel17)
                    .addComponent(jLabel16)
                    .addComponent(jLabel15))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtTennoidung, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(txtManoidung, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(txtMota, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(txtChiphi, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(txtMadungcu, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE)
                            .addComponent(txtMachiphi, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE))
                        .addGap(15, 15, 15)
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 493, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(69, 69, 69)
                        .addComponent(btnThem, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(52, 52, 52)
                        .addComponent(btnSua, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(57, 57, 57)
                        .addComponent(btnXoa, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(txtManoidung, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel13)
                            .addComponent(txtTennoidung, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(txtMota, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtMadungcu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtMachiphi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel16))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel17)
                            .addComponent(txtChiphi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnThem, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnXoa, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnSua, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(83, 83, 83))
        );

        jTabbedPane1.addTab("Quản lý nội dung tập", jPanel3);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/banner.PNG"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnthemthanhvienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnthemthanhvienActionPerformed
// TODO add your handling code here:
    connect obj = new connect();
    Connection con = obj.connect();
    
    String matv = txtmathanhvien.getText();
    String tentv = txttenthanhvien.getText();
    Object gt = cbbgioitinh.getSelectedItem();
    Date ngaysinh = cldngaysinh.getDate();
    String sdt = txtsdt.getText();
    String diachi = txtdiachi.getText();
    String tendn = txttendangnhap.getText();
    String matkhau = txtmatkhau.getText();
    String laimatkhau = txtlaimatkhau.getText();
    String date = null;
     
    
    
    
    if(btnthemthanhvien.getText().equals("Thêm Thành Viên"))
    {
        txtmathanhvien.setText("");
        txttenthanhvien.setText("");
        cbbgioitinh.setSelectedItem("Chọn giới rính");
        cldngaysinh.setDate(null);
        txtsdt.setText("");
        txtdiachi.setText("");
        txttendangnhap.setText("");
        txtmatkhau.setText("");
        txtlaimatkhau.setText("");
        
        txtmathanhvien.setEnabled(true);
        txttendangnhap.setEnabled(true);
        txtmatkhau.setEnabled(true);
        txtlaimatkhau.setEnabled(true);
        btnthemthanhvien.setText("Lưu Thành Viên");
    }
    else
    {   
        if(matv.equals("") || tentv.equals("") || gt.equals("Chọn giới tính") || tendn.equals("") || matkhau.equals(""))
        {
            JOptionPane.showMessageDialog(this,"Hãy nhập đủ thông tin !");
        }
        else
        {   
            if(btnthemthanhvien.getText().equals("Lưu Thành Viên"))
            {
                btnthemthanhvien.setText("Thêm Thành Viên");
            }
            btnThem.setText("Thêm Thành Viên");
            String sql2 = "select Ten from Dangnhap where Ten = '"+tendn+"'";
            try
            {
                rsthanhvien2 = obj.executeSQL(sql2); 
                if(rsthanhvien2.next())
                {
                    JOptionPane.showMessageDialog(this,"Tên Đăng nhập đã tồn tại !");
                }
                else
                {
                    int level = 1;
                    if(cbbcapdo.getSelectedItem().equals("Thành viên"))
                    {
                        level = 1;
                    }
                    else
                    {
                        level = 2;
                    }
                    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); 
                    date = formatter.format(ngaysinh);
                    String sql = "exec sp_Thanhvien_Insert N'"+matv+"',N'"+tentv+"',N'"+gt+"','"+date+"','"+sdt+"',N'"+diachi+"'";

                    String sql1 = "exec sp_Dangnhap_Insert '"+tendn+"','"+matkhau+"',"+level+"";
                    try
                    {
                        obj.executeUpdate(sql);
                        obj.executeUpdate(sql1);
                        JOptionPane.showMessageDialog(this,"Thêm thành viền thành công !");

                    }
                    catch(SQLException e)
                    {
                        e.printStackTrace();
                    }
                }
                }
                catch(SQLException e)
                {
                    e.printStackTrace();
                }


        }
        loadthanhvien();
    }
    
}//GEN-LAST:event_btnthemthanhvienActionPerformed

private void btnsuathanhvienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsuathanhvienActionPerformed
// TODO add your handling code here:
    connect obj = new connect();
    Connection con = obj.connect();
    
    String matv = txtmathanhvien.getText();
    String tentv = txttenthanhvien.getText();
    Object gt = cbbgioitinh.getSelectedItem();
    Date ngaysinh = cldngaysinh.getDate();
    String sdt = txtsdt.getText();
    String diachi = txtdiachi.getText();
    SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); 
    String date = formatter.format(ngaysinh); 
    String sql = "exec sp_Thanhvien_Update N'"+matv+"',N'"+tentv+"',N'"+gt+"','"+date+"','"+sdt+"',N'"+diachi+"'";
    
    try
    {
       int i = JOptionPane.showConfirmDialog(this,"Bạn có muốn sửa thông tin của thành viên này?",
                "Xóa thành viên",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
        if(i==0)
        {
            obj.executeUpdate(sql);
        }
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
    loadthanhvien();
    txtmathanhvien.setText("");
    txttenthanhvien.setText("");
    cbbgioitinh.setSelectedItem("Chọn giới tính");
    txtsdt.setText("");
    txtdiachi.setText("");
}//GEN-LAST:event_btnsuathanhvienActionPerformed

private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
// TODO add your handling code here:
    txttendangnhap.setEnabled(false);
    txtmatkhau.setEnabled(false);
    txtlaimatkhau.setEnabled(false);
    txtmathanhvien.setEnabled(false);
    btnSua.setEnabled(true);
    btnXoa.setEnabled(true);
            
    txtmathanhvien.setText(jTable1.getValueAt(jTable1.getSelectedRow(),0).toString());
    txttenthanhvien.setText(jTable1.getValueAt(jTable1.getSelectedRow(),1).toString());
    cbbgioitinh.setSelectedItem(jTable1.getValueAt(jTable1.getSelectedRow(),2).toString());
    String ngaysinh = jTable1.getValueAt(jTable1.getSelectedRow(),3).toString();
    DateFormat df=new SimpleDateFormat("dd/MM/yyyy");
        java.util.Date date = null;        
        try {
            date = df.parse(ngaysinh);
        } catch (ParseException ex) {
            Logger.getLogger(GiaodienAdmin.class.getName()).log(Level.SEVERE, null, ex);
        }
    cldngaysinh.setDate(date);
    txtsdt.setText(jTable1.getValueAt(jTable1.getSelectedRow(),4).toString());
    txtdiachi.setText(jTable1.getValueAt(jTable1.getSelectedRow(),5).toString());
}//GEN-LAST:event_jTable1MouseClicked

private void btnxoathanhvienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnxoathanhvienActionPerformed
// TODO add your handling code here:
    connect obj = new connect();
    Connection con = obj.connect();
            
    String Matv = jTable1.getValueAt(jTable1.getSelectedRow(),0).toString();
    String sql = "EXEC sp_Thanhvien_Delete N'"+Matv+"'";
    
    try
    {
        int i = JOptionPane.showConfirmDialog(this,"Bạn có muốn xóa thành viên này?",
                "Xóa thành viên",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
        if(i==0)
        {
            obj.executeUpdate(sql);
        }
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
    loadthanhvien();
}//GEN-LAST:event_btnxoathanhvienActionPerformed

private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
// TODO add your handling code here:
    
    
}//GEN-LAST:event_jTabbedPane1MouseClicked

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
    connect obj = new connect();
    Connection con = obj.connect();
    
    while(tblmodelthanhvien.getRowCount()>0)
    {
        tblmodelthanhvien.removeRow(0);
    }
    String sql = "SELECT Mathanhvien,Tenthanhvien,Gioitinh,convert(varchar(50),ngaysinh,103) as Ngaysinh,Dienthoai,Diachi "
            + "FROM Thanhvien "
            + "WHERE Tenthanhvien LIKE N'%"+txttimkiem.getText()+"%'";
    try
    {
        rsthanhvien1 = obj.executeSQL(sql);
        while(rsthanhvien1.next())
        {
            Vector v =new Vector();
            v.addElement(rsthanhvien1.getString("Mathanhvien"));
            v.addElement(rsthanhvien1.getString("Tenthanhvien"));
            v.addElement(rsthanhvien1.getString("Gioitinh"));
            v.addElement(rsthanhvien1.getString("Ngaysinh"));
            v.addElement(rsthanhvien1.getString("Dienthoai"));
            v.addElement(rsthanhvien1.getString("Diachi"));
            tblmodelthanhvien.addRow(v);
        }
       jTable1.setModel(tblmodelthanhvien);
    }
    catch(SQLException e)
    {
        e.printStackTrace();
    }
}//GEN-LAST:event_jButton1ActionPerformed

private void txttimkiemdungcuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txttimkiemdungcuActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_txttimkiemdungcuActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GiaodienAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GiaodienAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GiaodienAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GiaodienAdmin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new GiaodienAdmin().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSua;
    private javax.swing.JButton btnThem;
    private javax.swing.JButton btnXoa;
    private javax.swing.JButton btndcThem;
    private javax.swing.JButton btndcXoa;
    private javax.swing.JButton btnsuathanhvien;
    private javax.swing.JButton btnthemthanhvien;
    private javax.swing.JButton btntimkiemdungcu;
    private javax.swing.JButton btnxoathanhvien;
    private javax.swing.JComboBox cbbcapdo;
    private javax.swing.JComboBox cbbgioitinh;
    private com.toedter.calendar.JDateChooser cldngaysinh;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTable tabdungcu;
    private javax.swing.JTextField txtChiphi;
    private javax.swing.JTextField txtMachiphi;
    private javax.swing.JTextField txtMadungcu;
    private javax.swing.JTextField txtManoidung;
    private javax.swing.JTextField txtMota;
    private javax.swing.JTextField txtTennoidung;
    private javax.swing.JTextField txtdcChucnang;
    private javax.swing.JTextField txtdcGia;
    private javax.swing.JTextField txtdcMa;
    private javax.swing.JTextField txtdcNsx;
    private javax.swing.JTextField txtdcTen;
    private javax.swing.JTextField txtdiachi;
    private javax.swing.JPasswordField txtlaimatkhau;
    private javax.swing.JTextField txtmathanhvien;
    private javax.swing.JPasswordField txtmatkhau;
    private javax.swing.JTextField txtsdt;
    private javax.swing.JTextField txttendangnhap;
    private javax.swing.JTextField txttenthanhvien;
    private javax.swing.JTextField txttimkiem;
    private javax.swing.JTextField txttimkiemdungcu;
    // End of variables declaration//GEN-END:variables
}
